package controller;

import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@WebServlet("/ABCServlet")
public class ABCServlet extends HttpServlet {
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String account = request.getParameter("username");
		String passWord = request.getParameter("password");
		
		HttpSession session = request.getSession();
		String username = request.getParameter("username");
		String password = request.getParameter("password");

		userDao userDao = new userDao();	
		
		User user = (User)userDao.login(username, password);
		if (user != null) {
			session.setAttribute(username, user);
			request.getRequestDispatcher("check.jsp").forward(request, response);
			
		}else {
			request.getRequestDispatcher("hello.jsp").forward(request, response);
		}
	}
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
 
		doGet(request, response);
	}
 
}